package com.hongxun.entity;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.hongxun.budget.utils.SPUtils;

/**
 * 登录信息
 */

public class LoginInfo {


    public static void save(Context context, LoginInfo info) {
        loginInfo = info;
        String loginInfo = JSON.toJSONString(info);
        SPUtils.put(context, "LoginInfo", loginInfo);
    }

    public static void remove(Context context) {
        SPUtils.remove(context, "LoginInfo");
        loginInfo = null;
    }

    private static LoginInfo loginInfo;

    public static LoginInfo getInfo(Context context) {
        if (loginInfo == null) {
            String info = (String) SPUtils.get(context, "LoginInfo", "");
            loginInfo = JSON.parseObject(info, LoginInfo.class);
        }
        return loginInfo;
    }

    /**
     * userId : 1
     * username : admin
     * password : 9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d
     * salt : YzcmCZNvbXocrsz9dm8e
     * email : root@renren.io
     * mobile : 13612345678
     * status : 1
     * createTime : 2016-11-11 11:11:11
     * deptId : 1
     * deptName : 遵义供电公司
     */

    private Long userId;
    private String username;
    private String email;
    private String mobile;
    private Long deptId;
    private String deptName;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
}
